package cn.bellychang.abstractfactory.demo02;

/**
 * @author ChangLiang
 * @date 2020/1/16
 */
public class DataAccess {

    private String datasource;

    public DataAccess(String datasource) {
        this.datasource = datasource;
    }

    public IUser getUser() {
        IUser result = new SqlServerUser();
        switch (datasource) {
            case "SqlServer":
                result = new SqlServerUser();
                break;
            case "Access":
                result = new AccessUser();
                break;
            default:
                break;
        }
        return result;
    }

    public IDepartment getDepartment() {
        IDepartment result = new SqlServerDepartment();
        switch (datasource) {
            case "SqlServer":
                result = new SqlServerDepartment();
                break;
            case "Access":
                result = new AccessDepartment();
                break;
            default:
                break;
        }
        return result;
    }
}
